<!doctype  html>

<html>
<head>
    <meta charset="utf-8" />
    <title>www.meiweimimi.com/fqa/</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta http-equiv="imagetoolbar" content="no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7">
</head>
<body>

<style type="text/css">
    .file-box{ position:relative;width:340px}
    .txt{ height:22px; border:1px solid #cdcdcd; width:200px;border-right:none;}
    .btn{ background-color:#FFF; border:1px solid #CDCDCD;height:26px; width:70px;}
    .file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px }
</style>
<div class="file-box">
    <form action="" method="post" enctype="multipart/form-data">
        <input type='text' name='textfield' id='textfield' class='txt' /><input type='button' class='btn' value='浏览...' />
        <input type="file" name="fileField" class="file" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" />
    </form>
</div>
<div id="drag" style="font-size:20px;padding:25px;border:1px dashed #666;text-align:center;color:#bbb;margin-bottom:10px">
    <input type="file">
    将文件拖到此处
</div>


<script type="text/javascript" >

    function dropHandler(e)
    {
        e.stopPropagation();
        e.preventDefault();

        var files = e.dataTransfer.files;
        for(var i = 0, len = files.length; i < len; i++)
        {
            var f = files[i];
            console.log(f);
        }

    }

    function dragOverHandler(e)
    {
        e.stopPropagation();
        e.preventDefault();
        e.dataTransfer.dragEffect = 'copy'; //设置当拖拽到指定区域时，让文件可被复制
    }

    function dragStartHandler(e)
    {

    }

    var drag = document.getElementById('drag');
    drag.addEventListener('drop', dropHandler, false);
    drag.addEventListener('dragover', dragOverHandler, false);
    drag.addEventListener('dragover', dragStartHandler, false);

</script>

</body>
</html>